< previous page page_743 next page >

Page 743
0743-01.jpg
Figure 33.1
With the WebBrowser control, you
can add a live Web page to your from.
As you know, Web pages can contain graphics and other items, which can take a while to download. All of this happens asynchronously within the browser control while the rest of your VB program continues as normal. However, it would be nice to know when the Web page has been completely displayed. Notice that the sample form in Figure 33.1 includes a list box that displays the status of the browser. This was coded by using a just a few properties and events of the WebBrowser control:
The Busy property is a Boolean property that is True if the browser is in the process of communicating with the Web server. The sample in Figure 33.1 used a Timer control to repeatedly check this property and update the list box.
The Stop method is just like the Stop button on Internet Explorer. It could be used to stop the WebBrowser control from displaying the page if it is taking too long.
The DocumentComplete event is fired by the WebBrowser control when the Web site is completely displayed. This event does not fire if the WebBrowser control's Visible property is set to False.
Listing 33.1 provides the code necessary to create the sample shown in Figure 33.1.
Listing 33.1 BROWSER.ZIPUsing a WebBrowser Control
Private Sub cmdNavigate_Click()
    
    WebBrowser1.Visible = False
    WebBrowser1.Navigate txtURL.Text
    tmrMain.Enabled = True

End Sub

Private Sub tmrMain_Timer()

    If WebBrowser1.Busy = True Then
        lstStatus.AddItem "Working . . ."
continues

 
< previous page page_743 next page >